import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.5
import "./qml/menu/QmlInBookMenu"
import "./qml/menu/Qt5IntroductionProgramMenu"
import "./qml/menu/QmlFFmpegMenu"
import "./qml/menu/style"
import MyBaseSynctaxCpp 1.0
ApplicationWindow {
    x:0
    y:0
    height: Screen.height
    width: Screen.width
    visible: true

    title: qsTr("QML学习")
    Loader{
        id:mainLoader
        anchors.centerIn: parent
        anchors.fill: parent
    }
    //C++对象作为QML对象使用
    BaseSynctaxCpp{
        id:cpp_obj
        //可以随时增加对象属性
        //property int counts: 0
       // onAgeChanged: {
        //    counts++
        //    console.log("qml onAgeChanged",counts)
        //}
        //onCountsChanged: {
        //    console.log("qml onCountsChanged",counts)
       // }
    }
    //组件加载完成执行
    Component.onCompleted: {
        //关联信号与信号处理函数的方式同QML中的类型
        //Cpp对象的信号关联到QML
        //cpp_obj.onCppSignalA.connect(()=>console.log("qml signalA process"))
        //cpp_obj.onCppSignalIndex.connect(processShowInfo)

        //QML对象的信号关联到Cpp
        //qml_base_syntax_main_root.qmlSignalShowBaseSyntax.connect(cpp_obj.cppSlotA)
        //qml_base_syntax_main_root.onQmlSignalB.connect(cpp_obj.cppSlotB)
    }
    //定义的函数可以作为槽函数
    function processShowInfo(str,value){
        console.log("qml function processB",str,value)

    }
    menuBar: MenuBar{
        Menu{
            width: 150
            title: qsTr("QmlBook In Chinese")
            //QML语法
            QmlQuickStartMenu{}
            //动态元素
            FluidElementsMenu{}
            //模型视图
            ModelViewMenu{}
            //画布
            CanvasMenu{}
            //粒子
            ParticleMenu{}
            //着色器
            ShaderEffectMenu{}
            //多媒体
            MutilmediaMenu{}
            //网络
            NetWorkingMenu{}
            //存储
            StorageMenu{}
            //动态QML
            DynamicQmlMenu{}
            //JS
            JavaScriptMenu{}
            //C++
            QmlCppMenu{}
            //C++扩展QML
            ExtendQmlMenu{}
            delegate: GreenMenuItem{}
            background: GreenMenuBarBg{}
        }
        Menu{
            title: qsTr("Qt5编程入门")
            //第二章
            Chap2Menu{}
        }
        Menu{
            title: qsTr("QML高级")
            //各种牛B例子
        }
        Menu{
            title: qsTr("FFmpeg")
            QmlFFmpegMenu{}
        }

        delegate: GreenMenuBar{}
        background: GreenMenuBarBg {}
    }
}
